local hua__chaijun_shuaimiao = fk.CreateSkill {
  name = "hua__chaijun_shuaimiao",
  tags = { Skill.Compulsory }
}

Fk:loadTranslationTable {
  ["hua__chaijun_shuaimiao"] = "帅喵",
  [":hua__chaijun_shuaimiao"] = [[锁定技，你视为拥有有【花】的武将的武将牌上没有的非锁定技和行生技。]],
}

hua__chaijun_shuaimiao:addEffect(fk.EventAcquireSkill, {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return target:getMark("@hua__chaijun_xianhua") ~= 0 and player:hasSkill("hua__chaijun_shuaimiao")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_p = target
    if target_p:getMark("@hua__chaijun_xianhua") ~= 0 then
      local allskills_target = target_p:getSkillNameList()
      table.insertIfNeed(allskills_target, data.skill.name)
      local allskills_target_general = Fk.generals[target_p.general]:getSkillNameList()
      table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.general].related_other_skills)
      table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.general].related_skills)
      if target_p.deputyGeneral ~= "" then
        table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.deputyGeneral]:getSkillNameList())
        table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.deputyGeneral].related_other_skills)
        table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.deputyGeneral].related_skills)
      end
      local need_skills = table.filter(allskills_target, function(skillName, index, array)
        return not table.contains(allskills_target_general, skillName) and
            not Fk.skills[skillName]:hasTag(Skill.Compulsory)
      end)
      room:handleAddLoseSkills(player, need_skills)
    end
  end
})

hua__chaijun_shuaimiao:addEffect(fk.EventLoseSkill, {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return target:getMark("@hua__chaijun_xianhua") ~= 0 and player:hasSkill("hua__chaijun_shuaimiao") and
        not data.skill:hasTag(Skill.Compulsory)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local target_p = target
    local allskills_target_general = Fk.generals[target_p.general]:getSkillNameList()
    table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.general].related_other_skills)
    table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.general].related_skills)
    if target_p.deputyGeneral ~= "" then
      table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.deputyGeneral]:getSkillNameList())
      table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.deputyGeneral].related_other_skills)
      table.insertTableIfNeed(allskills_target_general, Fk.generals[target_p.deputyGeneral].related_skills)
    end
    local need_skills = table.contains(allskills_target_general, data.skill.name) and "" or "-" .. data.skill.name
    print(need_skills)
    room:handleAddLoseSkills(player, need_skills)
  end
})


return hua__chaijun_shuaimiao
